package data.promotion;
import java.util.Calendar;
import data.Record;




public class SaleGiftRecord extends Record {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private double price;
	
	private String gift_id;
	
	private int gift_num;
	
	private Calendar start_time;
	
	private Calendar end_time;
	
	
	public SaleGiftRecord(){
		
	}
	
	
	public SaleGiftRecord(double price,String gift_id,int gift_num,Calendar start_time,Calendar end_time){
		this.set(price, gift_id, gift_num, start_time, end_time);
	}
	
	
	public void set(double price,String gift_id,int gift_num,Calendar start_time,Calendar end_time){
		this.price=price;
		this.gift_id=gift_id;
		this.gift_num=gift_num;
		this.start_time=start_time;
		this.end_time=end_time;
	}
	
	
	public boolean isDuringTime(){
		Calendar time=Calendar.getInstance();
		return this.isDuringTime(time);
	}
	
	
	public boolean isDuringTime(Calendar time){
	    return (time.after(start_time)&&time.before(end_time));
	}
	
	
	public String getInfo(){
		String info=ID+","+price+","+gift_id+","+gift_num;
		String start=start_time.get(Calendar.YEAR)+"-"+start_time.get(Calendar.MONTH)+"-"+start_time.get(Calendar.DAY_OF_MONTH);
		String end=end_time.get(Calendar.YEAR)+"-"+end_time.get(Calendar.MONTH)+"-"+end_time.get(Calendar.DAY_OF_MONTH);
		info=info+","+start+","+end;
		return info;
	}
}
